package com.mediacloud.app.newsmodule.fragment;

import static com.mediacloud.app.nav2.fragment.HqyNavFragmentKt.FLAG_SCROLL_POSITION;
import static com.mediacloud.app.nav2.fragment.HqyNavFragmentKt.FLAG_SCROLL_TOP;

import com.eventTrack.CDPTrackReportManager;
import com.mediacloud.app.model.OnVideoPause;
import com.mediacloud.app.newsmodule.adaptor.component.Component116Holder;
import com.mediacloud.app.newsmodule.adaptor.video.vod.VideoNewsSimpleBigimgAndSpiderHolder;
import com.mediacloud.app.newsmodule.utils.CatalogType107Util;
import com.mediacloud.app.newsmodule.view.LocationChooseHeader;
import com.mediacloud.app.reslib.util.DataInvokeUtil;

import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Rect;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseIntArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.TextView;

import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;

import com.blankj.utilcode.util.NetworkUtils;
import com.eventTrack.TXReportManager;
import com.facebook.drawee.view.SimpleDraweeView;
import com.google.gson.Gson;
import com.jeremyliao.liveeventbus.LiveEventBus;
import com.mediacloud.app.assembly.clickutils.NoDoubleClickUtils;
import com.mediacloud.app.assembly.util.FunKt;
import com.mediacloud.app.assembly.util.Utility;
import com.mediacloud.app.fbnavsk.SecondFloorHandlerKt;
import com.mediacloud.app.fbnavsk.SecondNav;
import com.mediacloud.app.model.SmartRecommendEvent;
import com.mediacloud.app.model.adaptor.BaseAdaptor;
import com.mediacloud.app.model.component.ComponentItem;
import com.mediacloud.app.model.interfaces.InterfaceLayout;
import com.mediacloud.app.model.news.ArticleItem;
import com.mediacloud.app.model.news.ArticleListData;
import com.mediacloud.app.model.news.CMSFieldStyle;
import com.mediacloud.app.model.news.CatalogItem;
import com.mediacloud.app.model.news.kt.TypeX;
import com.mediacloud.app.model.view.floatwin.FloatButtonGroup;
import com.mediacloud.app.nav2.fragment.HqyNavFragment;
import com.mediacloud.app.newsmodule.BuildConfig;
import com.mediacloud.app.newsmodule.R;
import com.mediacloud.app.newsmodule.activity.NavigateActivity;
import com.mediacloud.app.newsmodule.adaptor.NewsListItemBaseAdaptor;
import com.mediacloud.app.newsmodule.adaptor.NewsListItemStyleAdaptor;
import com.mediacloud.app.newsmodule.adaptor.basenews.IAdapterRefresh;
import com.mediacloud.app.newsmodule.adaptor.bigimg_nosliceline.BigImageListAdaptor;
import com.mediacloud.app.newsmodule.adaptor.bigimg_nosliceline.BigImageNoSliceLineAdaptor;
import com.mediacloud.app.newsmodule.adaptor.component.BufferComponentContainer;
import com.mediacloud.app.newsmodule.adaptor.component.ComponentHolder;
import com.mediacloud.app.newsmodule.adaptor.component.IExposure;
import com.mediacloud.app.newsmodule.adaptor.component.ScrollExposure;
import com.mediacloud.app.newsmodule.adaptor.microdynamic.MicroDynamicCollectionHolder;
import com.mediacloud.app.newsmodule.fragment.newslist.ListDividerLayerUtilKt;
import com.mediacloud.app.newsmodule.fragment.newslist.TXRecommendFragment;
import com.mediacloud.app.newsmodule.fragment.video.vod.PlayClickListener;
import com.mediacloud.app.newsmodule.fragment.video.vod.VideoListPlayerUtil;
import com.mediacloud.app.newsmodule.utils.BindEventBus;
import com.mediacloud.app.newsmodule.utils.CacheDataKt;
import com.mediacloud.app.newsmodule.utils.LBSChooseListener;
import com.mediacloud.app.newsmodule.utils.NewsItemClickUtils;
import com.mediacloud.app.newsmodule.utils.TabLayoutColorKt;
import com.mediacloud.app.newsmodule.utils.ViewVisiblePercentToolKt;
import com.mediacloud.app.reslib.enums.AppFactoryGlobalConfig;
import com.mediacloud.app.reslib.enums.Navigate;
import com.mediacloud.app.reslib.enums.StyleOther;
import com.mediacloud.app.reslib.enums.ToolBarActionF5OrTop;
import com.mediacloud.app.reslib.enums.XKey;
import com.mediacloud.app.reslib.util.HomeTab;
import com.mediacloud.app.reslib.util.ViewHolder;
import com.mediacloud.app.view.XSmartRefreshLayout;
import com.outsource.factory.IOutsourceFactory;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
import com.tencent.mmkv.MMKV;
import com.utils.ClickUtils;
import com.utils.ExposurePoolService;
import com.utils.RxUtils;
import com.utils.SystemServiceManager;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import xyz.doikki.videoplayer.player.VideoView;

/**
 * 新闻内容列表页 不带banner
 */
@SuppressWarnings("ALL")
public class BaseNewsListFragmentX extends HqyNavFragment implements ToolBarActionF5OrTop, IOutsourceFactory, InterfaceLayout, OnItemClickListener, OnRefreshLoadMoreListener {
    public ListView mCatalogContentItemListView;
    protected TextView emptyTipsText;
    public CatalogType107Util catalogType107Util;
    @SuppressWarnings("rawtypes")
    public BaseAdaptor adaptor;
    protected String catalogID;
    protected int pageSize = 20;
    protected final String SaveAdaptor = "SaveAdaptor";
    protected CatalogItem catalogItem;
    //    protected LinearLayout headerViewContainer;
//    protected ComponentContainer componetContainer;
    protected BufferComponentContainer bufferComponentContainer;
    protected boolean haveBanner = false;
    protected boolean haveAddComponent31 = false;
    protected boolean haveAddComponent36 = false;

    protected XSmartRefreshLayout mXSmartRefreshLayout;
    protected View sohuHeaderView;

    protected FrameLayout layout_img;
    protected SimpleDraweeView simpleDraweeView;
    String titleName = "";

    /**
     * 上一次滚动停留的位置
     */
    protected int lastSelectedPosition;
    /**
     * 上一次滚动位置的偏差
     */
    protected int lastSelectedPositionOffset = 0;
    /**
     * 以这个作为一瓶显示数据的标记位，超过这个值就认为滚过了一屏
     */
    private int visibleItemCount = -1;
    /**
     * 第一屏最后一个元素显示在listView中显示的部分
     */
    private int firstPageLastItemOffset = 0;

    private SparseIntArray sparseArrayListViewItemHeight = new SparseIntArray();
    //    private int begin_position = 0;
//    private int stop_position = 0;
    int oldVisibleItem = 0;
    int oldScrollY = 0;
    public int visiblePosition = 0;
    public int firstPosition = 0;
    public int curPosition = -1;
    int mNetType;
    int lastVisibleItemPosition = 0;
    //    private ObjectAnimator translationX;
//    private ObjectAnimator translationX2;
    private boolean flag = false;
    public ListPreLoadKit<ArticleListData> preLoadKit;
    private int mLastRecordScrollY = 0;
    public int nid = 0;

    //标记，第一屏加载完，曝光事件
    private boolean isFisrtExposure = false;

    protected boolean needCache() {
        return true;
    }

    public ArrayList<Disposable> disposables = new ArrayList();

    protected AbsListView.OnScrollListener onScrollListener;
    private String mTab;

    boolean hideFlag = true;
    boolean showFlag = true;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //  String TAG = getClass().getCanonicalName();
        if (TXReportManager.getInstance().getFirstTabInfo() != null)
            mTab = TXReportManager.getInstance().getFirstTabInfo().getTabName();

        //Log.i(TAG, "onCreate fmg");
//        headerViewContainer = new LinearLayout(getActivity());
//        headerViewContainer.setOrientation(LinearLayout.VERTICAL);
//        componetContainer = new ComponentContainer(getActivity(), getCurrentICMP26Holder());
//        componetContainer.componentListItemStyleAdaptor.catalogItem = catalogItem;
//        headerViewContainer.addView(componetContainer);
        bufferComponentContainer = new BufferComponentContainer(requireContext());
        bufferComponentContainer.setPlayClickListener(playClickListener);
        bufferComponentContainer.setIcmp26Holder(getCurrentICMP26Holder());
    }

    public void toPreload(int preNum) {
        ExtendKt.preload(BaseNewsListFragmentX.this, preNum, null);
    }

    @SuppressWarnings({"unchecked", "rawtypes"})
    @Override
    public void initView() {
        loadingView = findViewById(R.id.mLoadingView);
        loadingView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                ClickUtils.delayClickable(v);
                if (currentState != TYPE_LOADING) {
                    showStateView(TYPE_LOADING, false);
                    doRefresh();
                }
            }
        });
        initStateView();
        showStateView(TYPE_LOADING, false);

        //
        layout_img = mRootView.findViewById(R.id.layout_img);
        simpleDraweeView = mRootView.findViewById(R.id.img_webp);


        mXSmartRefreshLayout = mRootView.findViewById(R.id.mXSmartRefreshLayout);
        preLoadKit = new ListPreLoadKit<ArticleListData>(requireContext(), mXSmartRefreshLayout) {
            @Override
            public void onSetData(ArticleListData data) {
                setData(data);
            }

            @Override
            public void onPreload(int preNum) {
                toPreload(preNum);
            }
        };
        mCatalogContentItemListView = Utility.findViewById(mRootView, R.id.mCatalogContentItemListView);
        mCatalogContentItemListView.setFriction(ViewConfiguration.getScrollFriction() * 2.5F);
        mCatalogContentItemListView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

            @Override
            public boolean onPreDraw() {
                try {

                    mCatalogContentItemListView.getViewTreeObserver().removeOnPreDrawListener(this);

                    if (mCatalogContentItemListView.getChildCount() == 0) return true;
                    int firstPosition = mCatalogContentItemListView.getFirstVisiblePosition();
                    View view = mCatalogContentItemListView.getChildAt(firstPosition);
                    while (view != null && (view.getHeight() == 0 || view.getVisibility() == View.GONE)) {
                        firstPosition++;
                        view = mCatalogContentItemListView.getChildAt(firstPosition);
                        if (firstPosition >= mCatalogContentItemListView.getChildCount()) {
                            break;
                        }
                    }

                    final int firstTop = mCatalogContentItemListView.getChildAt(mCatalogContentItemListView.getFirstVisiblePosition()).getTop();
                    final int lastBottom = mCatalogContentItemListView.getChildAt(mCatalogContentItemListView.getChildCount() - 1).getBottom();
                    //当前显示内容的高度
                    int totalHeight = lastBottom - firstTop;
                    //计算出第一屏的高度
                    visibleItemCount = mCatalogContentItemListView.getLastVisiblePosition();
                    int listViewHeight = mCatalogContentItemListView.getHeight();
                    if (totalHeight > listViewHeight) {//在这个情况下最后的一个元素没有显示完
                        View lastView = mCatalogContentItemListView.getChildAt(visibleItemCount);
                        if (lastView != null) {
                            while (visibleItemCount >= 0 && (lastView.getHeight() == 0 || lastView.getVisibility() == View.GONE)) {
                                visibleItemCount--;
                                lastView = mCatalogContentItemListView.getChildAt(visibleItemCount);
                            }
                            //计算最后一个元素的显示部分
                            firstPageLastItemOffset = lastView.getHeight() - (lastView.getBottom() - listViewHeight);
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return true;
            }
        });


        onScrollListener = new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
                // TODO Auto-generated method stub
                if (catalogType107Util != null) {
                    catalogType107Util.resumeOrPausePlayer(hadChoosed && getUserVisibleHint() && view.getFirstVisiblePosition() == 0, true);
                }
                setScrollerState(scrollState);
                if (AbsListView.OnScrollListener.SCROLL_STATE_IDLE == scrollState) {
                    if (scrollOverFirstPage() && !hasScrollerFlag(FLAG_SCROLL_POSITION)) {
                        setScrollerFlag(FLAG_SCROLL_POSITION);
                    } else if (!scrollOverFirstPage() && !hasScrollerFlag(FLAG_SCROLL_TOP)) {
                        setScrollerFlag(FLAG_SCROLL_TOP);
                    }
                    //    stop_position = Math.abs(getListViewScrollY());
                    if (catalogItem != null) {
//                        ReportManager.getInstance().scroll_page(String.valueOf(begin_position),
//                                String.valueOf(stop_position), MD5Utils.getMD5String(catalogItem.getName()), catalogItem.getName());
//                        begin_position = stop_position;
                        app_jhapp_home_subtab_content_imp();
                    }
                }
                //判断ListView是否滑动到第一个Item的顶部
                if (mXSmartRefreshLayout != null && mCatalogContentItemListView.getChildCount() > 0 && mCatalogContentItemListView.getFirstVisiblePosition() == 0 && mCatalogContentItemListView.getChildAt(0).getTop() >= mCatalogContentItemListView.getPaddingTop()) {
                    //解决滑动冲突，当滑动到第一个item，下拉刷新才起作用
                    mXSmartRefreshLayout.setEnableRefresh(enableRefresh);
                } else {
                    mXSmartRefreshLayout.setEnableRefresh(false);
                }
                if (scrollState == ListView.OVER_SCROLL_IF_CONTENT_SCROLLS) {
                    if (flag) {
                        return;
                    }
                    if (NoDoubleClickUtils.scrollRepeatOut()) {
                        return;
                    }
                    flag = true;
                    //鲜产品说是先注释掉动画效果
//                    if (FloatButtonGroup.animatorFlag) {
//                        if (translationX2 != null) {
//                            translationX2.cancel();
//                        }
//                        if (translationX != null) {
//                            translationX.start();
//                        }
//                    }
                }
                try {
                    //滑动停止后，
                    if (scrollState == ListView.OVER_SCROLL_ALWAYS) {
                        if (!hadChoosed) {
                            return;
                        }
                        flag = false;
//                        if (FloatButtonGroup.animatorFlag){
//                            if (translationX != null) {
//                                translationX.cancel();
//                            }
//                            if (translationX2 != null) {
//                                translationX2.start();
//                            }
//                        }
                        //检查网络是否可用
                        if (!checkNetType()) {
//                            if (mNetType != ConnectivityManager.TYPE_WIFI) {
//                                //Log.e("auto", "not wifi");
//                                return;
//                            }
                            return;
                        }

                        boolean isAutoPlay = MMKV.defaultMMKV().decodeBool(XKey.AUTO_PLAY, false);
                        if (!isAutoPlay && mNetType != ConnectivityManager.TYPE_WIFI) {
//                            Log.e("auto", "isAutoPlay: " + !isAutoPlay);
                            return;
                        }

                        int yPs = 0;//有地址选择的时候出现问题，加一个修正值
                        if (catalogItem != null && catalogItem.getLbsItem() != null) {
                            yPs = 1;
                        }
                        lastVisibleItemPosition = firstPosition == 0 ? 0 : firstPosition;
                        //是否自动播放


                        View itemView = null;
                        ArticleItem mArticleItem = null;
                        for (int i = 0; i < visiblePosition; i++) {
                            View tempItemView = mCatalogContentItemListView.getChildAt(i);
                            if (tempItemView != null && (tempItemView.getTop() >= 0 && ViewVisiblePercentToolKt.isFloatEquals(ViewVisiblePercentToolKt.getViewVisiblePercent(tempItemView), 1f))) {
                                //联播单独处理，下面旧逻辑使用列表数据的方式麻烦且有可能有bug
                                if (catalogType107Util != null) {
                                    Object tag = tempItemView.getTag();
                                    if (!hadChoosed) {
                                        return;
                                    }
                                    /*if (videoPosition == i) {
                                        return;
                                    }*/
                                    if (CatalogType107Util.isPlaying()) {
                                        /*if (mVideoListPlayerUtil != null) {
                                            mVideoListPlayerUtil.stopPlay();
                                        }*/
                                        return;
                                    } else if (tag instanceof VideoNewsSimpleBigimgAndSpiderHolder) {
                                        ((VideoNewsSimpleBigimgAndSpiderHolder) tag).cmsFieldBigImgTag.itemIcon.performClick();
                                        return;
                                    } else if (tag instanceof MicroDynamicCollectionHolder) {
                                        ((MicroDynamicCollectionHolder) tag).microDynamicHolder.autoPlayVideo();
                                        return;
                                    }
                                    continue;
                                }
                                //处理越界崩溃
                                int tempPosition = firstPosition + i - 1 - yPs;
//                                if (tempPosition>=0&&tempPosition<adaptor.getListContentData().size()) {
//                                    Log.e("auto", "tempItemView--top:" + tempItemView.getTop() + "----bottom:" + tempItemView.getBottom() +
//                                            "---viewHeight:" + tempItemView.getHeight() + "---firstPosition:" + firstPosition +"----visiblePosition:"+visiblePosition+
//                                            "---tempPosition:" + tempPosition + "---title:" + ((ArticleItem) adaptor.getListContentData().get(tempPosition)).getTitle());
//                                }
                                if (curPosition == tempPosition && tempPosition != -1) {
                                    return;
                                }
                                if ((tempPosition < 0) || (tempPosition >= adaptor.getListContentData().size())) {
                                    //Log.e("auto", "over size ");
                                    continue;
                                }
                                ArticleItem mTempArticleItem = (ArticleItem) adaptor.getListContentData().get(tempPosition);

                                if (mTempArticleItem.getType() == TypeX.NEWS.VIDEO) {
                                    if (mTempArticleItem.getCmsCustomStyle() != null && mTempArticleItem.getCmsCustomStyle().getType() != CMSFieldStyle.None) {
                                        if (mTempArticleItem.getCmsCustomStyle().getType() == CMSFieldStyle.BigImage16_9) {
                                            curPosition = tempPosition;
                                            mArticleItem = mTempArticleItem;
                                            //Log.e("auto", "curPosition: " + curPosition);
                                            itemView = tempItemView;
                                            break;
                                        }

                                    }
                                } else if (mTempArticleItem.getType() == TypeX.NEWS.MICRO_DYNAMIC) {
                                    Object tag = tempItemView.getTag();
                                    if ((tag instanceof ViewHolder) && isAutoPlay) {
                                        Object holder = ((ViewHolder) tag).getHolder();
                                        if (holder instanceof MicroDynamicCollectionHolder) {
                                            ((MicroDynamicCollectionHolder) holder).microDynamicHolder.autoPlayVideo();
                                        }
                                    }
                                } else {
                                    //Log.e("auto", "not video");
                                }
                            }
                        }
                        if (mArticleItem == null || TextUtils.isEmpty(mArticleItem.getVideo()) || mArticleItem.getVideo().equals("{}")) {
                            //Log.e("auto", "not have video path");
                            return;
                        }
                        if (!hadChoosed) {
                            return;
                        }

                        if (mArticleItem.getCmsCustomStyle() != null && mArticleItem.getCmsCustomStyle().getType() != CMSFieldStyle.None) {
                            if (mArticleItem.getCmsCustomStyle().getType() == CMSFieldStyle.BigImage16_9) {
                                if (itemView == null) {
                                    return;
                                }
                                View videoLayout = itemView.findViewById(R.id.bigImgAndSpiderStyle);
                                if (videoLayout != null) {
                                    View itemIcon = videoLayout.findViewById(R.id.itemIcon);
                                    if (isAutoPlay) {
                                        itemIcon.performClick();
                                    }
                                }
                            }

                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }


            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

                View firstVisibleView = mCatalogContentItemListView.getChildAt(firstVisibleItem);
                if (firstVisibleView != null) {
                    sparseArrayListViewItemHeight.put(firstVisibleItem, firstVisibleView.getHeight());
                }

                int listChildCount = mCatalogContentItemListView.getChildCount();
                for (int y = 0; y < listChildCount; y++) {
                    View itemView = mCatalogContentItemListView.getChildAt(y);

                    if (itemView instanceof BufferComponentContainer) {
                        int childCount = bufferComponentContainer.getContainer().getChildCount();
                        for (int i = 0; i < childCount; i++) {
                            View child = bufferComponentContainer.getContainer().getChildAt(i);
                            if (TXReportManager.getVisibility(child)) {
                                Object tag = child.getTag();
                                if (tag != null) {
                                    if (tag instanceof ScrollExposure) {
                                        Rect rect = new Rect();
                                        bufferComponentContainer.getLocalVisibleRect(rect);

                                        View ai_people = child.findViewById(R.id.ai_people);
                                        ObjectAnimator objectAnimatorX = null;
                                        if ((rect.top - 150) > child.getTop() || (rect.bottom + 150) < child.getBottom()) {
                                            if (ai_people.getX() >= 0 && hideFlag) {
                                                hideFlag = false;
                                                showFlag = true;
                                                objectAnimatorX = ObjectAnimator.ofFloat(ai_people, "translationX", -(Utility.dpToPx(getContext(), 170)));
                                                objectAnimatorX.setDuration(1000);
                                                objectAnimatorX.start();
                                            }
                                        } else {
                                            if (ai_people.getX() < 0 && showFlag) {
                                                hideFlag = true;
                                                showFlag = false;
                                                objectAnimatorX = ObjectAnimator.ofFloat(ai_people, "translationX", Utility.dpToPx(getContext(), 170));
                                                objectAnimatorX.setDuration(1000);
                                                objectAnimatorX.addListener(new Animator.AnimatorListener() {
                                                    @Override
                                                    public void onAnimationStart(Animator animator) {
                                                    }

                                                    @Override
                                                    public void onAnimationEnd(Animator animator) {
                                                        ((ScrollExposure) tag).startAnimation();
                                                    }

                                                    @Override
                                                    public void onAnimationCancel(Animator animator) {
                                                    }

                                                    @Override
                                                    public void onAnimationRepeat(Animator animator) {
                                                    }
                                                });
                                                objectAnimatorX.start();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }


                }
                visiblePosition = visibleItemCount;
                firstPosition = firstVisibleItem;
                if (mCatalogContentItemListView.getLastVisiblePosition() == (mCatalogContentItemListView.getCount() - 1)) {
                    preLoadKit.onLoadMore();
                }
            }
        };
        mCatalogContentItemListView.setOnScrollListener(onScrollListener);
        if (adaptor == null) {
            NewsListItemStyleAdaptor newsAdapter = new NewsListItemStyleAdaptor(getActivity(), playClickListener);
            newsAdapter.listView = mCatalogContentItemListView;
            adaptor = newsAdapter;
        }
        if (getFragmentArguments() != null) {
            saveInstanceArguments = getFragmentArguments();
            catalogID = saveInstanceArguments.getString("id");
            catalogItem = saveInstanceArguments.getParcelable("catalog");
        } else if (saveInstanceArguments != null) {
            catalogID = saveInstanceArguments.getString("id");
            catalogItem = saveInstanceArguments.getParcelable("catalog");
        }
        catalogType107Util = CatalogType107Util.getCatalogType107Util(catalogItem);
//        if (componetContainer != null) {
//            componetContainer.componentListItemStyleAdaptor.catalogItem = catalogItem;
//        }
        setNid(catalogID);
        //如果有其他样式的 就用这个列表样式了
        if (catalogItem != null && catalogItem.getCatalogStyle() == StyleOther.OtherStyle)//&&catalogItem.getStyleOther()!=null)
        {
            if (adaptor instanceof NewsListItemStyleAdaptor) {
                ((NewsListItemStyleAdaptor) adaptor).destroy();
            }
            adaptor = new BigImageNoSliceLineAdaptor(getActivity(), catalogItem, playClickListener);
        } else if (catalogItem != null && catalogItem.getCatalogStyle() == StyleOther.DEFAULT_BIG_IMAGE || catalogItem.getCatalogStyle() == StyleOther.PULL_BIG_IMAGE)//&&catalogItem.getStyleOther()!=null)
        {
            if (adaptor instanceof NewsListItemStyleAdaptor) {
                ((NewsListItemStyleAdaptor) adaptor).destroy();
            }
            adaptor = new BigImageListAdaptor(getActivity(), catalogItem, playClickListener);
        }

        addLBSChosoeHeader();

        if (getNavigate() != null && getNavigate().getSpecial_effect() == 1) {
            sohuHeaderView = LayoutInflater.from(getActivity()).inflate(R.layout.sohu_top_sign, null, false);
            mCatalogContentItemListView.addHeaderView(sohuHeaderView);
        }
        mCatalogContentItemListView.addHeaderView(bufferComponentContainer);
        mCatalogContentItemListView.setHeaderDividersEnabled(false);
        if (adaptor instanceof NewsListItemStyleAdaptor) {
            try {
                ((NewsListItemBaseAdaptor) adaptor).catalogItem = catalogItem;
            } catch (Exception e) {
                e.printStackTrace();
                //d(TAG, "" + e.getMessage());
            }
        }
        mCatalogContentItemListView.setFooterDividersEnabled(false);
        mCatalogContentItemListView.setAdapter(adaptor);
        mXSmartRefreshLayout.setEnableLoadMore(false);
        mXSmartRefreshLayout.setEnableRefresh(enableRefresh);
        mXSmartRefreshLayout.setOnRefreshLoadMoreListener(this);
        mCatalogContentItemListView.setOnItemClickListener(this);
        if (retryTips != null) {
            retryTips.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (!currentState.equals(TYPE_LOADING)) {
                        if (NetworkUtils.isConnected()) {
                            showStateView(TYPE_LOADING, false);
                            doRefresh();
                        }
                    }
                }
            });
        }

//        componetContainer.setmListView(this.mCatalogContentItemListView);
//        componetContainer.setRootView(mRootView);
        setRefreshLayoutColor(mXSmartRefreshLayout, getNavigate());
        beforeUserCache();
        new BindEventBus(this, adaptor);
        matchLBSCataglogId();

    }

    private boolean checkNetType() {
        ConnectivityManager cm = SystemServiceManager.getConnectivityManager(getContext());
        NetworkInfo networkInfo = cm.getActiveNetworkInfo();
        if (networkInfo != null && networkInfo.isAvailable()) {
            mNetType = networkInfo.getType();
            return true;
        }
        return false;
    }

    public int getScrollY() {
        View c = mCatalogContentItemListView.getChildAt(0);
        if (c == null) {
            return 0;
        }
        int firstVisiblePosition = mCatalogContentItemListView.getFirstVisiblePosition();
        int top = c.getTop();
        return -top + firstVisiblePosition * c.getHeight();
    }

    protected void addLBSChosoeHeader() {
        //LBS栏目不为空就加上头
        if (catalogItem != null && catalogItem.getLbsItem() != null) {
            int maxLBSH = getActivity().getResources().getDimensionPixelSize(R.dimen.dime_fifty);
            LocationChooseHeader locationChooseHeader = new LocationChooseHeader(getActivity());
            locationChooseHeader.catalogItem = catalogItem;
            locationChooseHeader.tag = FGTag.TagID;
//			mCatalogContentItemListView.addSecondHeader(maxLBSH,locationChooseHeader);
            locationChooseHeader.setVisiableHeight(maxLBSH);
            mCatalogContentItemListView.addHeaderView(locationChooseHeader);

        }
    }
    protected final void matchLBSCataglogId() {
        if (catalogItem != null && !TextUtils.isEmpty(catalogItem.getLbsNavigateDataId())) {
            catalogID = catalogItem.getLbsNavigateDataId();
            ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) loadingView.getLayoutParams();
            layoutParams.topMargin = getActivity().getResources().getDimensionPixelSize(R.dimen.dime_fifty);
            loadingView.requestLayout();
        }
    }

    @Override
    protected void initOther() {
        super.initOther();
//        if (getActivity() != null) {
//            useCache();
//        }
    }

    public void beforeUserCache() {

    }

    /**
     * listView是不是滚动超过第一屏的距离
     *
     * @return true 超过了第一屏的距离
     */
    private boolean scrollOverFirstPage() {

        return getListViewScrollY() > mCatalogContentItemListView.getHeight();
    }

    private int getListViewScrollY() {
        int firstVisiblePosition = mCatalogContentItemListView.getFirstVisiblePosition();
        int listViewScrollY = 0;
        for (int i = 0; i < firstVisiblePosition; i++) {
            listViewScrollY += sparseArrayListViewItemHeight.get(i, 0);
        }
        //添加第一个可见元素的高度
        View firstVisibleView = mCatalogContentItemListView.getChildAt(0);
        if (firstVisibleView != null) {
            listViewScrollY += -firstVisibleView.getTop();
        }
        return listViewScrollY;
    }


    @CallSuper
    @Override
    public void onViewCreated(@NonNull final View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mCatalogContentItemListView.setVerticalScrollBarEnabled(false);
        mCatalogContentItemListView.setHeaderDividersEnabled(false);
        mCatalogContentItemListView.setFooterDividersEnabled(false);
        mCatalogContentItemListView.setDividerHeight(view.getContext().getResources().getDimensionPixelOffset(R.dimen.dimen1));
        //  mCatalogContentItemListView.setSelector(R.color.transparent);
        if (hadChoosed) {
            SecondFloorHandlerKt.initFStyle(this, mXSmartRefreshLayout, sohuHeaderView);
        } else {
            SecondFloorHandlerKt.navPaddingTopMatch(this);
        }

        //变态的写法 先这样吧  用于向上遍历获取是否是时间轴导航的 不想改其他 感觉会有问题
        mCatalogContentItemListView.setTag(R.id.isFromTimeLineNav, false);
        //时间线导航 配置过样式才设置
        if (catalogItem != null && catalogItem.getCatalogStyle() != StyleOther.OtherStyle && AppFactoryGlobalConfig.FeatureModule.BigModule.TimeLineNav.equals(catalogItem.getCatalog_type()) && getNavigate() != null && getNavigate().getFont_selected() != null) {
            // mCatalogContentItemListView.setTag(R.id.timeLineColor, Nav2ParserKt.parseSelectedTxtColor(getNavigate(), view.getContext()));
            mCatalogContentItemListView.setTag(R.id.timeLineColor, ContextCompat.getColor(requireContext(), R.color.text_cctv7_red));
            mCatalogContentItemListView.setTag(R.id.isFromTimeLineNav, true);
            mCatalogContentItemListView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
                @Override
                public boolean onPreDraw() {
                    mCatalogContentItemListView.getViewTreeObserver().removeOnPreDrawListener(this);
                    int listWidth = mCatalogContentItemListView.getMeasuredWidth() - mCatalogContentItemListView.getPaddingStart() - mCatalogContentItemListView.getPaddingEnd();
                    if (listWidth <= 0) {
                        return true;
                    }
                    mCatalogContentItemListView.setDivider(ListDividerLayerUtilKt.generateDividerDrawable(view.getContext(), listWidth, TabLayoutColorKt.getTabLayoutStateColor(view.getContext(), getNavigate().getSecond_navigate()).second));
                    mCatalogContentItemListView.setDividerHeight(view.getContext().getResources().getDimensionPixelOffset(R.dimen.dimen2));
                    return true;
                }
            });
        }
    }

    @org.jetbrains.annotations.Nullable
    @Override
    public Navigate getNavigate() {
        if (catalogItem != null && catalogItem.getNavigate() != null)
            return catalogItem.getNavigate();
        return super.getNavigate();
    }


    @Override
    public void onDestroyView() {
        if (catalogType107Util != null) {
            catalogType107Util.destroy();
        }
        if (mVideoListPlayerUtil != null) {
            mVideoListPlayerUtil.onDestroy();
            mVideoListPlayerUtil = null;
        }

        if (bufferComponentContainer != null) {
            bufferComponentContainer.setPlayClickListener(null);
        }

        if (playClickListener != null) {
            playClickListener = null;
        }

        ExtendKt.releaseData(this);
        // LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(mReceiver);

        if (adaptor != null) {
            if (adaptor instanceof NewsListItemStyleAdaptor) {
                ((NewsListItemStyleAdaptor) adaptor).destroy();
            }
            if (adaptor instanceof BigImageNoSliceLineAdaptor) {
                ((BigImageNoSliceLineAdaptor) adaptor).destroy();
            }
        }

//        if (mXSmartRefreshLayout != null) {
//            mXSmartRefreshLayout.setOnRefreshLoadMoreListener(null);
//        }
        if (mCatalogContentItemListView != null) {
            mCatalogContentItemListView.setOnItemClickListener(null);
            mCatalogContentItemListView.setAdapter(null);
        }
//        if (componetContainer != null) {
//            componetContainer.dispose();
//            componetContainer = null;
//        }

        if (mXSmartRefreshLayout != null) {
            mXSmartRefreshLayout.setOnLoadMoreListener(null);
            mXSmartRefreshLayout.setOnRefreshListener(null);
        }

        if (mVideoListPlayerUtil != null) {
            mVideoListPlayerUtil.onDestroy();
        }
        super.onDestroyView();
        if (!(requireActivity() instanceof NavigateActivity)) {
            TXReportManager.getInstance().clearThirdAndFourTabInfo();

        }
    }

    @Override
    public void onDestroy() {
        FragmentPreInflateHelper.onDestoryView();
        super.onDestroy();
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        if (FunKt.isFastClick()) {
            int index = position;
            index = index - mCatalogContentItemListView.getHeaderViewsCount();
            if (index < 0) return;
            ArticleItem item = (ArticleItem) adaptor.getItem(index);
            if (item == null) {
                return;
            }
            item.setPositionInList(index);
            item.setParentId(catalogID);
            TextView titleView = view.findViewById(R.id.newsTitle);
            TextView newsVRTitle = view.findViewById(R.id.newsVRTitle);
            TextView zhiding = view.findViewById(R.id.text_title);//置顶组件
            TextView cmsTitle = view.findViewById(R.id.tv_title_v2);//cms样式
            TextView videoTitle = view.findViewById(R.id.titleTv);//视频导航
            TextView bigImgTitle = view.findViewById(R.id.itemTitle);//大图无分割线
            if (titleView != null) titleView.setTextColor(Color.parseColor("#666666"));
            if (newsVRTitle != null) newsVRTitle.setTextColor(Color.parseColor("#666666"));
            if (zhiding != null) zhiding.setTextColor(Color.parseColor("#666666"));
            if (cmsTitle != null) cmsTitle.setTextColor(Color.parseColor("#666666"));
            if (videoTitle != null) videoTitle.setTextColor(Color.parseColor("#666666"));
            if (bigImgTitle != null) bigImgTitle.setTextColor(Color.parseColor("#666666"));
            NewsItemClickUtils.OpenItemNewsHandle(getActivity(), item.getType(), item, catalogItem);

            checkReport(item,position);


        }


    }

    /**
     * 进入首页二级板块内合集类内容列表页进行互动时，例如点击查看详情时/点击播放时等
     * 我们可以理解未在父类activity为NavigateActivity时触发
     */
    private void checkReport(ArticleItem item,int position) {
        TXReportManager txReportManager = TXReportManager.getInstance();
        TXReportManager.getInstance().app_jhapp_radio_content_interact(item, "点击播放", null, catalogItem);
        if ("电台".equals(TXReportManager.getInstance().getSecondName()) && TXReportManager.getInstance().isMoreListPage()) {
            TXReportManager.getInstance().app_jhapp_radio_more_content_interact(item, catalogItem.getName());
        } else if ("首页".equals(txReportManager.getFirstTabInfo().getTabName()) /*&& !HomeTab.isAtHome()*/) {
            CDPTrackReportManager.getInstance().NewsRPClick(position,item,null);
            //txReportManager.app_jhapp_home_subtab_more_content_interact("点击查看详情", item);
        }
       /* else if (txReportManager.getFirstTabInfo().getTabName().equals("首页") && txReportManager.getCurrentNavigate().getTabName().endsWith("详情页")) {
            txReportManager.app_jhapp_home_subtab_more_content_interact("点击查看详情", item);
        } else if (txReportManager.getFirstTabInfo().getTabName().equals("首页") && txReportManager.getCurrentNavigate().getTabName().equals("智库") && txReportManager.getThirdTabInfo().getTabName() != null) {
            txReportManager.app_jhapp_home_subtab_more_content_interact("点击查看详情", item);
        } else if (txReportManager.getFirstTabInfo().getTabName().equals("军媒")) {
            if (txReportManager.getCurrentNavigate().getTabName() != null) {
                txReportManager.app_jhapp_home_subtab_more_content_interact("点击查看详情", item);
            }
        } */
        else if ("视频".equals(txReportManager.getFirstTabInfo().getTabName())) {
            txReportManager.app_jhapp_video_interact("点击查看详情", catalogItem.getName(), item);
        } else if ("留言".equals(txReportManager.getFirstTabInfo().getTabName())){
            CDPTrackReportManager.getInstance().LeaveWordsClick(item, position);
        }else{
            if (!(requireActivity() instanceof NavigateActivity)) {
                TXReportManager.getInstance().app_jhapp_home_subtab_content_interact("点击查看详情", catalogItem.getName(), catalogItem.getName(), "", "", "", "", "", item);
            }
        }
        txReportManager.app_jhapp_explore_service_interact("点击查看详情", item, item.getPositionInList(), catalogItem.getName());

    }

    public VideoListPlayerUtil mVideoListPlayerUtil;
    public PlayClickListener playClickListener = new PlayClickListener() {
        @Override
        public void onPlayIcoClick(View rootView, ViewGroup container, View playIcon, final ArticleItem item) {
            mCatalogContentItemListView.postDelayed(new Runnable() {
                @Override
                public void run() {
                    if (catalogType107Util != null) {
                        catalogType107Util.enforcePausePlayer();
                    }
                    if (mVideoListPlayerUtil == null) {
                        mVideoListPlayerUtil = new VideoListPlayerUtil(getActivity(), mCatalogContentItemListView, BaseNewsListFragmentX.this);
                        mVideoListPlayerUtil.setHqyNavFragment(BaseNewsListFragmentX.this);
                        if (catalogType107Util != null) {
                            mVideoListPlayerUtil.playStateCallBack = new RxUtils.CallBack<Integer>() {
                                @Override
                                public void call(int playState, Integer integer) {
                                    if (playState == VideoView.STATE_PLAYING) {
                                        catalogType107Util.enforcePausePlayer();
                                    }
                                }
                            };
                        }
                        if (getParentFragment() instanceof SecondNav) {
                            mVideoListPlayerUtil.mPlayer.setViewPlayer(((SecondNav) getParentFragment()).getViewPager());
                        }
                    }
                    if (item != null && mVideoListPlayerUtil.item != null && mVideoListPlayerUtil.getPlayer() != null && mVideoListPlayerUtil.item.equals(item) && mVideoListPlayerUtil.getPlayer().isPlaying()) {
                        return;
                    }
                    mVideoListPlayerUtil.setPlayerContainer(rootView, container, playIcon, !TextUtils.isEmpty(item.getGoodsID()), new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            item.setParentId(catalogID);
                            NewsItemClickUtils.OpenItemNewsHandle(getActivity(), item.getType(), item, catalogItem);
                        }
                    }, item);
                    if (item.getType() == TypeX.NEWS.MICRO_DYNAMIC)
                        mVideoListPlayerUtil.isAutoPlayVideo = true;
                    else mVideoListPlayerUtil.isAutoPlayVideo = false;
                    mVideoListPlayerUtil.setVideoDetail(catalogID + "", item);
                }
            }, catalogType107Util == null ? 50 : 300);

        }
    };


    @Override
    public int getLayoutResID() {
        return R.layout.fragment_catalog_itemcontent;
    }

    @Override
    public View getLayoutView() {
        return FragmentPreInflateHelper.getInstance(getContext()).getView(getLayoutResID(), getClass());
    }

    @SuppressWarnings("rawtypes")
    public void setAdaptor(BaseAdaptor adaptor) {
        this.adaptor = adaptor;
    }


    boolean checkInited = false;


    @CallSuper
    public void doRefresh() {
//        if (componetContainer != null) {
//            componetContainer.stopWindows();
//            componetContainer.stopUpSmallVideoUi();
//        }
        CatalogType107Util.needNotifyList = false;
        preLoadKit.onRefresh();
        hideFlag = true;
        showFlag = true;
        ExtendKt.getData(BaseNewsListFragmentX.this, null);
    }

    private void useCache() {
        String refreshData = MMKV.mmkvWithID(XKey.HOME_REFRESH_DATA).getString(catalogID, null);
        MMKV.mmkvWithID(XKey.HOME_REFRESH_DATA).clear();
        if (!TextUtils.isEmpty(refreshData)) {
            ArticleListData articleListData = new ArticleListData();
            try {
                //TODO
                articleListData.readFromJson(new JSONObject(refreshData));
                preLoadKit.setHasMore(articleListData.more);
                preLoadKit.getPreLoadData().add(articleListData);
                showStateView(TYPE_LOADING, false);
                setData(articleListData);
                preLoadKit.preload();
            } catch (JSONException e) {
                e.printStackTrace();
                innerUserCache();
            }
        } else {
            innerUserCache();
        }
    }

    private void innerUserCache() {
        ArticleListData dataResult = CacheDataKt.readData(this, catalogID, ArticleListData.class);
        if (adaptor != null && dataResult.articleList.size() > 0 || dataResult.componentItems.size() > 0) {
            showStateView(TYPE_LOADING, false);
            setData(dataResult);
        } else {
            showStateView(TYPE_LOADING, false);
            doRefresh();
        }
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        //   registerMulti();
    }

    @Override
    public void onPause() {

        super.onPause();
        mResume = false;
        setComponentItemsVisibleHint();
        if (mVideoListPlayerUtil != null) {
            mVideoListPlayerUtil.addViewHistory();
        }
//        if (componetContainer != null && componetContainer.mMultiVideoPlayer != null) {
//            if (MultiVideoMannager.getInstace().isHandPause) {
//            } else {
//                componetContainer.mMultiVideoPlayer.onPause();
//            }
//        }
    }

    @Override
    public void onResume() {
        mResume = true;
        setComponentItemsVisibleHint();
        curPosition = -1;
        visiblePosition = 0;
        firstPosition = 0;
//        if (componetContainer != null && componetContainer.mMultiVideoPlayer != null) {
//            if (MultiVideoMannager.getInstace().isHandPause) {
//
//            } else {
//                componetContainer.mMultiVideoPlayer.onStart();
//            }
//        }
        if (emptyTipsText == null) {
            emptyTipsText = Utility.findViewById(mRootView, R.id.emptyTipsText);
        }
        super.onResume();
        if(catalogType107Util!=null&&getUserVisibleHint()
                &&mCatalogContentItemListView!=null&&mCatalogContentItemListView.getGlobalVisibleRect(new Rect())
            && hadChoosed){
            CatalogType107Util.resumePlayer(false);
        }

    }

//
//    private void registerMulti() {
//
//        IntentFilter filter = new IntentFilter();
//        filter.addAction(MultiUtils.outFullbord);
//        filter.addAction(MultiUtils.closeThe);
//
//        LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mReceiver, filter);
//    }
//
//    BroadcastReceiver mReceiver = new BroadcastReceiver() {
//        @Override
//        public void onReceive(Context context, Intent intent) {
//
//            String action = intent.getAction();
//            Log.i("test", "mReceiver action:" + action);
//            if (action != null) {
//                if (componetContainer != null && componetContainer.mMultiVideoPlayer != null) {
//
//                    if (action.equals(MultiUtils.outFullbord)) {
//                        componetContainer.mMultiVideoPlayer.outFullScreen();
//                    } else if (action.equals(MultiUtils.closeThe)) {
//                        stopThePlayer();
//                        isExcode = false;
//                    }
//                }
//
//
//            }
//
//
//        }
//    };


    @CallSuper
    @Override
    public void unChosoed() {
        super.unChosoed();
        if (mVideoListPlayerUtil != null) {
            mVideoListPlayerUtil.stopPlay();
        }
        if (catalogType107Util != null) catalogType107Util.resumeOrPausePlayer(false, false);
        //     stopThePlayer();
    }

    boolean isExcode = false;

//    private void stopThePlayer() {
//        if (componetContainer != null && !isExcode) {
//            componetContainer.stopWindows();
//            //componetContainer.mMultiVideoPlayer.stopPlay();
//            componetContainer.stopUpSmallVideoUi();
//            isExcode = true;
//        }
//        MultiVideoMannager.getInstace().isHiden = true;
//
//    }


    @CallSuper
    @Override
    public void choosed() {
        super.choosed();
        if (getActivity() == null || requireActivity().isFinishing() || requireActivity().isDestroyed() || isDetached() || isRemoving()) {
            return;
        }
        if (getActivity() != null) {
            mRootView.post(() -> {
                SecondFloorHandlerKt.initFStyle(BaseNewsListFragmentX.this, mXSmartRefreshLayout, sohuHeaderView);
            });
        }
        if (catalogType107Util != null) catalogType107Util.resumeOrPausePlayer(true, false);
        isExcode = false;
        showBottomDivide();
        if (isAdded() && mCatalogContentItemListView != null) {
            app_jhapp_home_subtab_content_imp();
        }
    }

    public void initToRefresh() {

        if (getActivity() == null || requireActivity().isFinishing() || requireActivity().isDestroyed()) {
            return;
        }
        if (ExtendKt.getSearchId() != null || this instanceof TXRecommendFragment) {//从搜索跳过来直接加载，不走缓存
            showStateView(TYPE_LOADING, false);
            doRefresh();
        } else {
            useCache();
        }

    }

    protected void showBottomDivide() {
        Fragment fragment = getRootFragment();
        if (fragment instanceof SecondNav) {
            SecondNav secondNav = (SecondNav) fragment;
            try {
                //1 2 代表新浪和搜狐的二楼效果 参考的SecondFloorHandler.kt
                if (getNavigate() != null && (getNavigate().getSpecial_effect() == 1 || getNavigate().getSpecial_effect() == 2) && secondNav.getSecondTabIsNotOnToolBar()) {
                    secondNav.setTableBottomDivideVisible(false);
                } else {
                    secondNav.setTableBottomDivideVisible(true);
                }
            } catch (Exception e) {
                e.printStackTrace();
                secondNav.setTableBottomDivideVisible(true);
            }
        }
    }

    @CallSuper
    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        setComponentItemsVisibleHint();
        if (catalogType107Util != null)
            catalogType107Util.resumeOrPausePlayer(isVisibleToUser, false);
        //Log.i("test", "player:setUserVisibleHint");
        if (getUserVisibleHint()) {
            // isVisible = true;
            //   isExcode=false;
            //Log.i("test", "player:hiden?:visible");
        } else {

            //Log.i("test", "player:hiden?:GONE");
            if (mVideoListPlayerUtil != null) {
                mVideoListPlayerUtil.stopPlay();
            }

            // isVisible = false;
        }
        curPosition = -1;
        visiblePosition = 0;
        firstPosition = 0;
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        //Log.i("test", "player:onHiddenChanged:" + hidden);
        curPosition = -1;
        visiblePosition = 0;
        firstPosition = 0;
        if (hidden) {
            if (mVideoListPlayerUtil != null) {
                mVideoListPlayerUtil.stopPlay();
            }

//            if (componetContainer != null) {
//                componetContainer.stopWindows();
//                componetContainer.stopUpSmallVideoUi();
//            }
//            MultiVideoMannager.getInstace().isHiden = true;
        } else {

        }
    }


    @NotNull
    @Override
    public View getInterceptView() {
        return mCatalogContentItemListView;
    }

    @Override
    public final void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        //Log.w(ListPreLoadKit.Companion.getLTAG(), "触发了 RefreshLayout onLoadMore");

        preLoadKit.getMoreDate();
    }

    @Override
    public final void onRefresh(@NonNull RefreshLayout refreshLayout) {
        doRefresh();
    }

    @Override
    public final void f5() {
        if (getScrollerState()) {
            mCatalogContentItemListView.smoothScrollToPosition(0);
        } else {
            mCatalogContentItemListView.setSelection(0);
        }
        mXSmartRefreshLayout.setEnableRefresh(enableRefresh);
        mXSmartRefreshLayout.autoRefresh(200);
    }

    @Override
    public final void gun() {
        //这里也会滚动到顶部，处理一下滚动状态
        setScrollParams();
        setScrollerFlag(FLAG_SCROLL_TOP);
        if (getScrollerState()) {
            mCatalogContentItemListView.smoothScrollToPosition(0);
        } else {
            mCatalogContentItemListView.setSelection(0);
        }
    }

    @Override
    public boolean handleScroller() {
        if (hasScrollerFlag(FLAG_SCROLL_TOP)) {
            setScrollerFlag(FLAG_SCROLL_POSITION);
            mCatalogContentItemListView.setSelectionFromTop(lastSelectedPosition, lastSelectedPositionOffset);
            return true;
        }
        if (hasScrollerFlag(FLAG_SCROLL_POSITION)) {
            setScrollParams();
            setScrollerFlag(FLAG_SCROLL_TOP);
            mXSmartRefreshLayout.getRefreshKernel().moveSpinner(0, false);
            mCatalogContentItemListView.requestFocusFromTouch();
            mCatalogContentItemListView.setSelection(0);
            return true;
        }
        return true;
    }

    private void setScrollParams() {
        lastSelectedPosition = mCatalogContentItemListView.getFirstVisiblePosition();
        View view = mCatalogContentItemListView.getChildAt(0);
        if (view != null) {
            lastSelectedPositionOffset = view.getTop();
        }
    }

    protected void setContentData(String ids) {

        Map<String, String> params = new HashMap<>();
        params.put("article_id", ids);//获取文稿的详情信息

        DataInvokeUtil.ziMeiTiApi.getArticleContent(params).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<JSONObject>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(JSONObject jsonObject) {
                if (jsonObject.optBoolean("state")) {
                    JSONArray data = jsonObject.optJSONArray("data");
                    for (int i = 0; i < data.length(); i++) {
                        try {
                            JSONObject json = new JSONObject(data.get(i).toString());
                            String article_id = json.optString("article_id");
                            String content = json.optString("content");
                            for (int j = 0; j < cachArticleItem.size(); j++) {
                                if (article_id.equals(cachArticleItem.get(j).optString("id"))) {
                                    cachArticleItem.get(j).put("content", content);
                                }
                            }

                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                    }
                    MMKV.mmkvWithID(catalogID).clearAll();
                    String s = new Gson().toJson(cachArticleItem);
                    MMKV.mmkvWithID(catalogID).putString(XKey.DETAIL_CACHE, s);
                }
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    private List<JSONObject> cachArticleItem = new ArrayList<>();
    private StringBuffer ids = new StringBuffer();

    private void cache() {
        cachArticleItem.clear();
        ids.delete(0, ids.length());
        try {


            int listChildCount = mCatalogContentItemListView.getChildCount();
            for (int y = 0; y < listChildCount; y++) {
                View itemView = mCatalogContentItemListView.getChildAt(y);
                if (itemView instanceof BufferComponentContainer) {
                    List<ComponentItem> list = bufferComponentContainer.getAdapter().getListContentData();
                    for (int i = 0; i < list.size(); i++) {
                        JSONObject jsonObject = new JSONObject(list.get(i).getOrginData());
                        JSONArray jsonArray = jsonObject.getJSONArray("element");
                        for (int d = 0; d < jsonArray.length(); d++) {
                            JSONObject articleItem = new JSONObject(jsonArray.get(d).toString());
                            if (articleItem.getString("type").equals("1") && cachArticleItem.size() < 10) {
                                if (ids.toString().length() > 0) {
                                    ids.append("," + articleItem.getLong("id"));
                                } else {
                                    ids.append(articleItem.getLong("id"));
                                }
                                cachArticleItem.add(articleItem);
                            }
                        }
                    }

                }
            }

            List<ArticleItem> metalist = adaptor.getListContentData();
            if (cachArticleItem.size() < 10) {
                for (int i = 0; i < 10 - cachArticleItem.size(); i++) {
                    if (metalist.get(i).getType() == 1) {
                        if (ids.toString().length() > 0) {
                            ids.append("," + metalist.get(i).getId());
                        } else {
                            ids.append(metalist.get(i).getId());
                        }
                        String s = new Gson().toJson(metalist.get(i));
                        cachArticleItem.add(new JSONObject(s));
                    }

                }
            }

//            for (int j = 0; j < cachArticleItem.size(); j++) {
//                cachArticleItem.get(j).put("content","<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"https://web.test.mjh.pladaily.com.cn/cms/rmt9502/css/cssbase.css\"><meta name = \"format-detection\" content = \"telephone=no\"><meta name=\"viewport\" content=\"width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no\"><style>@font-face{font-family: appfactoryClientFont;src: url(\"APPFACTORY_CLIENT_LOCAL_FONT_SRC\");}body * {font-family: appfactoryClientFont;word-wrap: break-word;}</style></head><body ><div style=\"font-size:18px;line-height:1.5;\" id=\"editWrap\"><p style=\"text-align:left;line-height:2;padding-top:5px;padding-bottom:5px;\"><span style=\"font-size: 18px;\"><span style=\"font-family: 宋体;\">中国航天日|弘扬航天精神 拥抱星辰大海</span></span></p><p style=\"text-align:left;line-height:2;padding-top:5px;padding-bottom:5px;\"><span style=\"font-size: 18px;\"><span style=\"font-family: 宋体;\">来源：中国军网</span></span><span style=\"font-size: 18px;\"><span style=\"font-family: 宋体;\"> 作者：赵晶晶 张硕 </span></span></p><p style=\"text-align:center;line-height:2;padding-top:5px;padding-bottom:5px;\"><img border=\"0\" style=\"max-width:100%;width: 553px; height: 782px;\" zcmsimagerela=\"103400\" src=\"https://web.test.mjh.pladaily.com.cn/cms/rmt9502/upload/Image/mrtp/2022/03/29/7623b710d06141b9bf2614dce7e777bb.png?picturesize=960x0\" alt=\"7623b710d06141b9bf2614dce7e777bb.png\"></p><p style=\"text-align:left;line-height:2;padding-top:5px;padding-bottom:5px;\"><span style=\"font-size: 18px;\"><span style=\"font-family: 宋体;\">今天，在“东方红一号”卫星成功发射50周年之际，我们迎来了第五个“中国航天日”。</span></span></p><p style=\"text-align:left;line-height:2;padding-top:5px;padding-bottom:5px;\"><span style=\"font-size: 18px;\"><span style=\"font-family: 宋体;\">从“两弹一星”到“载人航天”，从“北斗组网”到“嫦娥探月”，一代代航天工作者秉承航天精神，勇攀科技高峰，创造了中国航天事业发展的辉煌成就。</span></span></p><p style=\"text-align:left;line-height:2;padding-top:5px;padding-bottom:5px;\"><span style=\"font-size: 18px;\"><span style=\"font-family: 宋体;\">探索浩瀚宇宙，发展航天事业，建设航天强国，是我们不懈追求的航天梦。从航天大国到航天强国，我们的航天梦必将绚丽绽放！</span></span></p><p></p></div></body><script type=\"text/javascript\">const imgDefault = '';var imgEle = document.getElementsByTagName('img');for (var i = 0; i < imgEle.length; i++) {    imgEle[i].setAttribute('title', '');    if(imgEle[i].getAttribute('src') == ''){        imgEle[i].setAttribute('src', imgDefault);    }    imgEle[i].addEventListener(\"error\", function (e) {        var ele = e.target;        ele.src = imgDefault;        ele.onerror = null;    })}// video、audio去除所有的title属性var videoEle = document.getElementsByTagName('video');for (var i = 0; i < videoEle.length; i++) {    videoEle[i].setAttribute('title', '');}var audioEle = document.getElementsByTagName('audio');for (var i = 0; i < audioEle.length; i++) {    audioEle[i].setAttribute('title', '');}// 兼容安卓上面样式差异（莫名换行）  cssbase无法实现var sectionEle = document.querySelectorAll(\"section[powered-by]\");for (var i = 0; i < sectionEle.length; i++) {  if(sectionEle[i].children[0] && sectionEle[i].children[0].tagName == 'SECTION' && sectionEle[i].children[0].getAttribute('style') && sectionEle[i].children[0].getAttribute('style').indexOf('width: 50%;') > -1){    const styleStr = 'display: flex;' + sectionEle[i].getAttribute('style');    sectionEle[i].setAttribute('style', styleStr);  }}function setupWebViewJavascriptBridge(callback) {    if (window.WebViewJavascriptBridge) {        return callback(WebViewJavascriptBridge);    }    if (window.WVJBCallbacks) {        return window.WVJBCallbacks.push(callback);    }    window.WVJBCallbacks = [callback];    var WVJBIframe = document.createElement('iframe');    WVJBIframe.style.display = 'none';    WVJBIframe.src = 'https://__bridge_loaded__';    document.documentElement.appendChild(WVJBIframe);    setTimeout(function () {        document.documentElement.removeChild(WVJBIframe)    }, 0)}var userInfo = '';var sign = '';var act_id = \"\";var u = navigator.userAgent,    app = navigator.appVersion,    reqData = {};function userInfoMsg() {    if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {        userInfo = JSON.parse(window.android.morefunObjcGetUserInfo(true));    } else if (!!u.match(/\\(i[^;]+;( U;)? CPU.+Mac OS X/) || u.indexOf('iPhone') > -1 || u.indexOf('iPad') > -1) {        setupWebViewJavascriptBridge(function (bridge) {            bridge.callHandler('morefunObjcGetUserInfo', { \"needLogin\": true }, function (response) {                userInfo = JSON.parse(response);            });        });    }}var timestamp = new Date().getTime().toString();timestamp = Number(timestamp.slice(0, -3));function userInfoSign() {    let data = userInfo;    reqData = {        act_id: act_id,        group_id: data.userInfo.groupId,        OpenID: data.userInfo.userid,        Timestamp: timestamp,        uid: data.userInfo.userid,        avatar: data.userInfo.avatar,        TenantID: data.tenantID,        SourceID: data.userInfo.platforms ? data.userInfo.platforms : data.userInfo.platform,        userid: data.userInfo.userid,        mobile: data.userInfo.mobile,        nickname: data.userInfo.nickname,        token: data.userInfo.token,        SecretKey: 'defaultAPP'    };    if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {        sign = window.android.mfsign(JSON.stringify(reqData));    } else if (!!u.match(/\\(i[^;]+;( U;)? CPU.+Mac OS X/) || u.indexOf('iPhone') > -1 || u.indexOf('iPad') > -1) {        setupWebViewJavascriptBridge(function (bridge) {            bridge.callHandler('morefunObjcCallback', reqData, function (response) {                let sign1 = decodeURI(response);                let mfSignStr = sign1.split(\"&\");                for (var i = 0; i < mfSignStr.length; i++) {                    if (mfSignStr[i].split(\"=\")[0] == 'mfSign') {                        sign = unescape(mfSignStr[i].split(\"=\")[1]);                    }                }            });        });    }}window.addEventListener(    'message',    e => {        if (typeof e.data == 'object') {            if (e.data.key == 'activityWH') {                let actData = e.data.value;                document.getElementById(actData.actId).contentWindow.postMessage(                    {                        key: 'activityIsApp',                        value: 'true'                    },                    '*'                );                act_id = actData.actId;                $(\"#video_content\").find('iframe').each(function () {                    if ($(this).attr(\"id\") == act_id) {                        //window.confirm(JSON.stringify(actData));                        $(this).css({ \"width\": actData.width, \"height\": actData.height })                    }                });            } else if (e.data.key == 'activityLogin') {                let actData = e.data.value;                userInfoMsg();                setTimeout(function () {                    userInfoSign();                }, 100);                setTimeout(function () {                    userInfo.timestamp = timestamp;                    if (userInfo.userInfo.userid) {                        document.getElementById(actData).contentWindow.postMessage(                            {                                key: 'activityUserInfo',                                value: {                                    sign: sign,                                    userInfo: userInfo                                }                            },                            '*'                        );                    };                }, 200);            } else if (e.data.key == 'getUserId') {                let actData = e.data.value;                userInfoMsg();                setTimeout(function () {                    userInfoSign();                }, 100);                setTimeout(function () {                    userInfo.timestamp = timestamp;                    if (userInfo.userInfo.userid) {                        document.getElementById(actData).contentWindow.postMessage(                            {                                key: 'actUserInfo',                                value: {                                    isOnAPP: 'true',                                    userInfo: userInfo                                }                            },                            '*'                        );                    };                }, 200);            }        }    })</script></html>");
//            }
//            String s = new Gson().toJson(cachArticleItem);
//            MMKV.mmkvWithID(catalogID).putString(XKey.DETAIL_CACHE,s);

            setContentData(ids.toString());


        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    protected boolean needUpdateComponent = true;

    public boolean isAddFooterEmptyArticleItem = false;

    public ArticleListData mArticleListData;

    public Boolean realVisible = null;
    public Boolean showVisible = false;
    boolean mResume = false;

    public void setComponentItemsVisibleHint() {
        if (mCatalogContentItemListView != null && adaptor != null && adaptor.getListContentData().size() > 0) {
            showVisible = getUserVisibleHint() && isVisible() && mResume;
        } else {
            showVisible = false;
        }

        if (mArticleListData != null && mArticleListData.componentItems != null && mArticleListData.componentItems.size() > 0) {
            boolean newVisible = getUserVisibleHint() && isVisible() && mResume;
            if (realVisible != null && realVisible.booleanValue() == newVisible) {
                return;
            } else {
                realVisible = newVisible;
            }
            /*if (catalogItem != null) {
                Log.d("tag", "sssssssssssss" + catalogItem.getName() + "-" + newVisible);
            } else {
                Log.d("tag", "sssssssssssss" + catalogID + "-" + newVisible);
            }*/
            for (ComponentItem item : mArticleListData.componentItems) {
                item.realVisible = realVisible;
                if (mTab != null) {
                    item.tabName = mTab;
                }
            }
        }
    }


    //设置数据
    public void setData(ArticleListData result) {
        if (getActivity() == null || requireActivity().isFinishing() || requireActivity().isDestroyed()) {
            return;
        }
        if (catalogType107Util != null) {
            catalogType107Util.addTimeHolderData(getContext(), mCatalogContentItemListView, this, preLoadKit.getPageNum() == 1, result);
        }
        mArticleListData = result;
        realVisible = null;
        setComponentItemsVisibleHint();
        if (preLoadKit.getPageNum() == 1 && !preLoadKit.getHasMore() && result.articleList != null && result.articleList.size() != 0) {
            ArticleItem footerEmptyArticleItem = new ArticleItem();
            footerEmptyArticleItem.setType(TypeX.CUSTOM.Footer_Empty);
            result.articleList.add(footerEmptyArticleItem);
            isAddFooterEmptyArticleItem = true;
        }
        if (adaptor == null) return;

        if (preLoadKit.getPageNum() == 1) {
            curPosition = -1;
            visiblePosition = 0;
            firstPosition = 0;
            if (result.orginData != null) {
                JSONObject data = result.orginData.optJSONObject("data");
                if (FloatButtonGroup.haveFloatField(data)) {
                    initFloatWin(data);
                } else {
                    hideFloatWin();
                }
            }
            mXSmartRefreshLayout.finishRefresh();
            mXSmartRefreshLayout.finishLoadMore();
            if (adaptor instanceof IAdapterRefresh) {
                ((IAdapterRefresh) adaptor).refresh();
            }
            if (adaptor.getListContentData() != null) {
                adaptor.getListContentData().clear();
            }
            //添加组件  用的HeadView
            if (needUpdateComponent) {
                //     componetContainer.updateComponent(result.componentItems);
                for (int i = 0; i < result.componentItems.size(); i++) {
                    result.componentItems.get(i).belongNavId = catalogID;
                }
                bufferComponentContainer.setData(result.componentItems, catalogItem);
            }
        }

        ListPreLoadTool.preLoad(requireContext(), result.articleList);
        if (adaptor.getListContentData() == null) {
            adaptor.setListContentData(result.articleList);
        } else {
            adaptor.getListContentData().addAll(result.articleList);
        }
        adaptor.notifyDataSetChanged();

        if (preLoadKit.getPageNum() == 1) {

            boolean isCacheData = false;
            if (ExtendKt.getSearchId() == null) //搜索页面不存数据
                if (needCache() && result.orginData != null) {
                    isCacheData = result.orginData.optInt("is_cache", 0) == 1;
                    if (!isCacheData) {
                        try {
                            result.orginData.put("is_cache", 1);
                            CacheDataKt.saveData(BaseNewsListFragmentX.this, catalogID, result.orginData + "");
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }
            if (isCacheData) {
//                mXSmartRefreshLayout.autoRefresh(500);
                //原刷新方法
                // onRefresh(mXSmartRefreshLayout);
                //首次执行时执行下拉动画，有执行动画记录后进行无动画刷新
                if (catalogType107Util==null&&!com.utils.FragmentInitUtil.isInit(getActivity(), this, catalogID)) {
                    com.utils.FragmentInitUtil.addFragment(getActivity(), this, catalogID);
                    mXSmartRefreshLayout.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            mXSmartRefreshLayout.autoRefresh();
                        }
                    }, 50);
                } else {
                    onRefresh(mXSmartRefreshLayout);
                }

            } else {
                if (preLoadKit.getPageNum() == 1) {
                    dataReady = true;
                    if (hadChoosed) {
                        app_jhapp_home_subtab_content_imp();
                    }
                }
            }
            //触发一下 onScrollStateChanged 否则 视频不会自动播放
            mCatalogContentItemListView.postDelayed(new Runnable() {
                @Override
                public void run() {
                    if (onScrollListener != null) {
                        onScrollListener.onScrollStateChanged(mCatalogContentItemListView, AbsListView.OnScrollListener.SCROLL_STATE_IDLE);
                    }
                }
            }, 300);
        }
//                mXSmartRefreshLayout.postDelayed(new Runnable() {
//                    @Override
//                    public void run() {
//                        if (getActivity() == null || requireActivity().isFinishing() || requireActivity().isDestroyed() || isDetached() || isRemoving()) {
//                            return;
//                        }
//                        if (result!=null&&result.articleList!=null&&result.articleList.size()>=pageSize){
//                            mXSmartRefreshLayout.setEnableFooterFollowWhenLoadFinished(false);
//                        }else{
//                            mXSmartRefreshLayout.setEnableFooterFollowWhenLoadFinished(true);
//                        }
//                    }
//                },500);


        if (isAddFooterEmptyArticleItem) {
            if (needUpdateComponent && (adaptor.getListContentData() == null || adaptor.getListContentData().size() == 0) && result.componentItems.size() == 0) {
                showStateView(TYPE_NO_CONTENT, false);
            } else {
                closeStateView();
            }
        } else {
            if (needUpdateComponent && (adaptor.getListContentData() == null || adaptor.getListContentData().size() == 0) && result.componentItems.size() == 0) {
                showStateView(TYPE_NO_CONTENT, false);
            } else {
                closeStateView();
            }
        }
        LiveEventBus.get(XKey.FINISH_MODE).post(true);
    }


    public void onSaveInstanceState(Bundle outState) {
        outState.putString("id", catalogID);
        outState.putParcelable("catalog", catalogItem);
        super.onSaveInstanceState(outState);
    }

    @CallSuper
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == LBSChooseListener.Request && resultCode == Activity.RESULT_OK)
            LBSChooseListener.getInstance().onActivityResult(data, this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onNotIntresting(NotIntrestEvent event) {
        List<ArticleItem> list = adaptor.getListContentData();
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getId() == event.getId()) {
                list.remove(list.get(i));
                adaptor.notifyDataSetChanged();
            }
        }
    }

    public boolean dataReady = false;
    //点击首页二级板块内合集类内容且内容列表曝光时（只上报用户停止滑动且呈现在屏幕上1秒以上的内容，滚动过程中的数据无需上报）
    private Runnable app_jhapp_home_subtab_content_impRunable = new Runnable() {
        @Override
        public void run() {
            ExposurePoolService.getExecutorService().execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        int listChildCount = mCatalogContentItemListView.getChildCount();
                        for (int y = 0; y < listChildCount; y++) {
                            View itemView = mCatalogContentItemListView.getChildAt(y);
                            if (itemView instanceof BufferComponentContainer) {
                                int childCount = bufferComponentContainer.getContainer().getChildCount();
                                for (int i = 0; i < childCount; i++) {
                                    View view = bufferComponentContainer.getContainer().getChildAt(i);
                                    //判断View可见了才采集数据
                                    if (TXReportManager.getVisibility(view)) {
                                        Object tag = null;
                                        List<ComponentItem> list = bufferComponentContainer.getAdapter().getListContentData();
                                        try {
                                            //因为ComponentListItemStyleAdaptor 里 判断了 C99993 是这样设置的tag,咱也不敢改啊,只有这样去写
                                            if (list.get(i).getWidget() == TypeX.COMPONENT.C99993) {
                                                tag = view.getTag(R.id.component3_viewholder);
                                            } else {
                                                tag = view.getTag();
                                            }
                                        } catch (Exception e) {
                                            e.printStackTrace();
                                        }
                                        if (tag != null) {
                                            if (tag instanceof IExposure) {
                                                List<ArticleItem> articleItemList = ((IExposure) tag).getExposureArticles();
                                                if (articleItemList != null) {
                                                    ComponentItem componentItem = ((IExposure) tag).getExposureComponentItem();
                                                    String componentTitle = "";
                                                    if (componentItem != null) {
                                                        if (!TextUtils.isEmpty(componentItem.getTitle())&& !componentItem.getTitle().contains("https")) {
                                                            componentTitle = componentItem.getTitle();
                                                        }
                                                        if (TextUtils.isEmpty(componentTitle)) {
                                                            if (TextUtils.isEmpty(componentItem.getSname())) {
                                                                if (!TextUtils.isEmpty(componentItem.getName())) {
                                                                    componentTitle = componentItem.getName();
                                                                }
                                                            } else {
                                                                componentTitle = componentItem.getSname();
                                                            }
                                                        }
                                                    }
                                                    Collections.reverse(articleItemList);
                                                    for (int k = 0; k < articleItemList.size(); k++) {
                                                        ArticleItem article = articleItemList.get(k);
                                                        article.setPositionInList(k);
                                                        CDPTrackReportManager.getInstance().NewsRPExpose(k,article,componentTitle);
                                                        checkReport2(article, componentTitle, itemView, k, componentItem);
                                                    }
                                                }
                                            } else {
                                                if (tag instanceof ComponentHolder) {
                                                    //这里是 还没实现IExposure的组件先不管了。遇到了在加
                                                    if (BuildConfig.DEBUG) {
                                                        Log.w("XYADDD", "未实现IExposure " + tag.getClass().getSimpleName());
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            } else {
                                //这里先取一下组件3的tag
                                Object tag = itemView.getTag(R.id.component3_viewholder);
                                if (tag == null) {
                                    tag = itemView.getTag();
                                }
                                if (tag != null) {
                                    if (tag instanceof IExposure) {
                                        List<ArticleItem> articleItemList = ((IExposure) tag).getExposureArticles();
                                        ComponentItem componentItem = ((IExposure) tag).getExposureComponentItem();
                                        String componentTitle = "";
                                        if (componentItem != null) {
                                            if (!TextUtils.isEmpty(componentItem.getTitle())) {
                                                componentTitle = componentItem.getTitle();
                                            }
                                            if (TextUtils.isEmpty(componentTitle)) {
                                                if (TextUtils.isEmpty(componentItem.getSname())) {
                                                    if (!TextUtils.isEmpty(componentItem.getName())) {
                                                        componentTitle = componentItem.getName();
                                                    }
                                                } else {
                                                    componentTitle = componentItem.getSname();
                                                }
                                            }
                                        }
                                        if (TextUtils.isEmpty(componentTitle)) {
                                            if (!TextUtils.isEmpty(catalogItem.getName())) {
                                                titleName = catalogItem.getName();
                                            }
                                        } else {
                                            titleName = componentTitle;
                                        }
                                        if (articleItemList != null) {
                                            for (int k = 0; k < articleItemList.size(); k++) {
                                                ArticleItem article = articleItemList.get(k);
                                                article.setPositionInList(k);
                                                TXReportManager.getInstance().app_jhapp_home_subtab_content_imp(article, componentItem, catalogItem);
                                                if (BaseNewsListFragmentX.this instanceof TXRecommendFragment) {
                                                    if (article != null) {
                                                        TXReportManager.getInstance().app_jhapp_rec_content_exp(null, null, article.getId() + "", TXReportManager.getInstance().getContentShowType(article.getType()));
                                                    }
                                                }
                                                TXReportManager.getInstance().app_jhapp_explore_service_cntnt_imp(article, k, titleName);
                                                if (TXReportManager.getInstance().getFirstTabInfo().getTabName().equals("军媒")) {
                                                    if ("杂志".equals(TXReportManager.getInstance().getCurrentChannelInfo().getTabName())) {
                                                        TXReportManager.getInstance().app_jhapp_magazine_imp(article);
                                                    }
                                                }
                                            }
                                        }
                                    } else {
                                        if (tag instanceof ComponentHolder) {
                                            //这里是 还没实现IExposure的组件先不管了。遇到了在加
                                            if (BuildConfig.DEBUG) {
                                                Log.w("XYADDD", "未实现IExposure " + tag.getClass().getSimpleName());
                                            }
                                        } else {
                                            //这里是列表数据
                                            listMeta(itemView);
                                        }
                                    }
                                } else {
                                    //这里是列表数据
                                    listMeta(itemView);
                                }
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }

    };


    private void checkReport2(ArticleItem article, String componentTitle, View itemView, int i, ComponentItem componentItem) {
        if (TextUtils.isEmpty(componentTitle)) {
            if (!TextUtils.isEmpty(catalogItem.getName())) {
                titleName = catalogItem.getName();
            }
        } else {
            titleName = componentTitle;
        }
        if ("电台".equals(TXReportManager.getInstance().getCurrentChannelInfo().getTabName()) && TXReportManager.getInstance().isMoreListPage()) {
            TXReportManager.getInstance().app_jhapp_radio_more_content_imp(article, titleName);
        }
        if ("电台".equals(TXReportManager.getInstance().getCurrentChannelInfo().getTabName())) {
            TXReportManager.getInstance().app_jhapp_radio_content_imp(article, titleName);
        }
        TXReportManager.getInstance().app_jhapp_home_subtab_content_imp(article, componentItem, catalogItem);
        if (BaseNewsListFragmentX.this instanceof TXRecommendFragment) {
            if (article != null) {
                TXReportManager.getInstance().app_jhapp_rec_content_exp(null, null, article.getId() + "", TXReportManager.getInstance().getContentShowType(article.getType()));
            }
        }
        TXReportManager.getInstance().app_jhapp_explore_service_cntnt_imp(article, i, titleName);
        if (TXReportManager.getInstance().getFirstTabInfo().getTabName().equals("军媒")) {
            if ("杂志".equals(TXReportManager.getInstance().getCurrentChannelInfo().getTabName())) {
//                    TXReportManager.getInstance().app_jhapp_magazine_imp(article);
            }
        } else if (TXReportManager.getInstance().getFirstTabInfo().getTabName().equals("首页") && !TextUtils.isEmpty(TXReportManager.getInstance().getMoreTitle())) {
            TXReportManager.getInstance().app_jhapp_home_subtab_more_content_imp(article);
        } else if (TXReportManager.getInstance().getFirstTabInfo().getTabName().equals("视频")) {
            TXReportManager.getInstance().app_jhapp_video_imp(componentTitle, article, i);
        }

    }

    private void listMeta(View itemView) {
        try {
            int articlePosition = mCatalogContentItemListView.getPositionForView(itemView);
            ArticleItem articleItem = (ArticleItem) adaptor.getListContentData().get(articlePosition - mCatalogContentItemListView.getHeaderViewsCount());
            articleItem.setPositionInList(articlePosition - mCatalogContentItemListView.getHeaderViewsCount());
            titleName = catalogItem.getName();
            if ("电台".equals(TXReportManager.getInstance().getCurrentChannelInfo().getTabName()) && TXReportManager.getInstance().isMoreListPage()) {
                TXReportManager.getInstance().app_jhapp_radio_more_content_imp(articleItem, titleName);
            }
            if ("电台".equals(TXReportManager.getInstance().getCurrentChannelInfo().getTabName())) {
                TXReportManager.getInstance().app_jhapp_radio_content_imp(articleItem, titleName);
            }
            if ("留言".equals(TXReportManager.getInstance().getFirstTabInfo().getTabName())){
                CDPTrackReportManager.getInstance().LeaveWordsRPExpose(articleItem,articlePosition);
            }else{
                CDPTrackReportManager.getInstance().NewsRPExpose(articlePosition,articleItem,null);
            }
            TXReportManager.getInstance().app_jhapp_home_subtab_content_imp(articleItem, null, catalogItem);
            if (this instanceof TXRecommendFragment) {
                if (articleItem != null) {
                    TXReportManager.getInstance().app_jhapp_rec_content_exp(null, null, articleItem.getId() + "", TXReportManager.getInstance().getContentShowType(articleItem.getType()));
                }
            }
            TXReportManager.getInstance().app_jhapp_explore_service_cntnt_imp(articleItem, articlePosition, titleName);
            if (TXReportManager.getInstance().getFirstTabInfo().getTabName().equals("军媒")) {
                if ("杂志".equals(TXReportManager.getInstance().getCurrentChannelInfo().getTabName())) {
                    TXReportManager.getInstance().app_jhapp_magazine_imp(articleItem);
                } else if ("电台".equals(TXReportManager.getInstance().getCurrentChannelInfo().getTabName())) {
                    if (TXReportManager.getInstance().getCurrentNavigate().getTabName() != null) {
                        if (TXReportManager.getInstance().getCurrentNavigate().getTabName().endsWith("详情页")) {
                            TXReportManager.getInstance().app_jhapp_home_subtab_more_content_imp(articleItem);
                        }
                    }
                }

            } else if (TXReportManager.getInstance().getFirstTabInfo().getTabName().equals("首页") && !TextUtils.isEmpty(TXReportManager.getInstance().getMoreTitle())) {
                TXReportManager.getInstance().app_jhapp_home_subtab_more_content_imp(articleItem);
            } else {
                if ("视频".equals(TXReportManager.getInstance().getFirstTabInfo().getTabName())) {
                    TXReportManager.getInstance().app_jhapp_video_imp(catalogItem.getName(), articleItem, articlePosition);
                }
            }


        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void app_jhapp_home_subtab_content_imp() {
        if (!dataReady) return;
        if (mCatalogContentItemListView != null && showVisible) {
            mCatalogContentItemListView.removeCallbacks(app_jhapp_home_subtab_content_impRunable);
            mCatalogContentItemListView.postDelayed(app_jhapp_home_subtab_content_impRunable, TXReportManager.EXPOSURE_DELAY);
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onRefreshData(SmartRecommendEvent recommendEvent) {
        f5();
    }

    public boolean isShowLive() {
        return mCatalogContentItemListView != null && mCatalogContentItemListView.getFirstVisiblePosition() == 0;
    }
}